package TestClass;

import javax.servlet.GenericServlet;

import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.IOException;


@WebServlet("/arequest1")
public class Session2Test extends GenericServlet {

    @Override
    public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {
        //1开启会话，向下转型
        HttpServletRequest servletRequest1=(HttpServletRequest) servletRequest;
        HttpSession session = servletRequest1.getSession();
        String ok = (String) session.getAttribute("ok");
        String ok1 = (String) session.getAttribute("ok1");
        System.out.println("ok = " + ok);
        System.out.println("ok1 = " + ok1);
    }
}
